package com.atguigu02._class;

import org.junit.Test;

public class ClassTest {
    /*
    获取Class实例的几种方式（掌握前三种）
    */
    @Test
    public void t1() throws ClassNotFoundException {
        //1.调用运行时类的静态属性
        Class<User> clazz1 = User.class;
        //2.调用运行时类的对象的getClass()方法
        User user1 = new User();
        Class clazz2=user1.getClass();
        System.out.println(clazz1);
        System.out.println(clazz1 == clazz2);//true
        //3．调用Class的静态方法forName(String className)
        String s="com.atguigu02._class.User";
        Class clazz3 = Class.forName(s);
        System.out.println(clazz3 == clazz1);//true


    }
}
